﻿@model OrderSettingsModel
@{
    ViewBag.Title = T("Admin.Configuration.Settings.Order").Text;
}

@using (Html.BeginForm())
{
    <div class="section-header">
        <div class="title">
            <i class="far fa-chart-bar"></i>
            @T("Admin.Configuration.Settings.Order")
        </div>
        <div class="options">
            <button type="submit" name="save" value="save" class="btn btn-warning">
				<i class="fa fa-check"></i>
				<span>@T("Admin.Common.Save")</span>
			</button>
        </div>
    </div>

    Html.RenderAction("StoreScopeConfiguration", "Setting");

    @Html.ValidationSummary(false)

    @Html.SmartStore().TabStrip().Name("ordersettings-edit").Style(TabsStyle.Material).Items(x =>
    {
		x.Add().Text(T("Admin.Configuration.Settings.Order.OrderSettings").Text).Content(TabOrderSettings()).Selected(true);
		x.Add().Text(T("Admin.Configuration.Settings.Order.ReturnRequestSettings").Text).Content(TabReturnRequestSettings());

		//generate an event
		EngineContext.Current.Resolve<IEventPublisher>().Publish(new TabStripCreated(x, "ordersettings-edit", this.Html, this.Model));
    })
}

@helper TabOrderSettings()
{
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.IsReOrderAllowed)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.IsReOrderAllowed)
                @Html.ValidationMessageFor(model => model.IsReOrderAllowed)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.MinOrderSubtotalAmount)
            </td>
            <td class="adminData">
				@Html.SettingEditorFor(model => model.MinOrderSubtotalAmount, null, new { postfix = Model.PrimaryStoreCurrencyCode })
                @Html.ValidationMessageFor(model => model.MinOrderSubtotalAmount)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.MinOrderTotalAmount)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.MinOrderTotalAmount, null, new { postfix = Model.PrimaryStoreCurrencyCode })
                @Html.ValidationMessageFor(model => model.MinOrderTotalAmount)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.AnonymousCheckoutAllowed)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.AnonymousCheckoutAllowed)
                @Html.ValidationMessageFor(model => model.AnonymousCheckoutAllowed)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.TermsOfServiceEnabled)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.TermsOfServiceEnabled)
                @Html.ValidationMessageFor(model => model.TermsOfServiceEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.DisableOrderCompletedPage)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.DisableOrderCompletedPage)
                @Html.ValidationMessageFor(model => model.DisableOrderCompletedPage)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.GiftCards_Activated_OrderStatusId)
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.GiftCards_Activated_OrderStatusId, Model.GiftCards_Activated_OrderStatuses, T("Common.PleaseSelect").Text)
                @Html.ValidationMessageFor(model => model.GiftCards_Activated_OrderStatusId)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.GiftCards_Deactivated_OrderStatusId)
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.GiftCards_Deactivated_OrderStatusId, Model.GiftCards_Deactivated_OrderStatuses, T("Common.PleaseSelect").Text)
                @Html.ValidationMessageFor(model => model.GiftCards_Deactivated_OrderStatusId)
            </td>
        </tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.OrderListPageSize)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.OrderListPageSize)
				@Html.ValidationMessageFor(model => model.OrderListPageSize)
			</td>
		</tr>
        @if (Model.OrderIdent.HasValue)
        {
            <tr>
                <td class="adminTitle">
                    @Html.SmartLabelFor(model => model.OrderIdent)
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.OrderIdent)
                </td>
            </tr>
        }
		@if (Model.StoreCount > 1)
		{
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.DisplayOrdersOfAllStores)
				</td>
				<td class="adminData">
					@Html.SettingEditorFor(model => model.DisplayOrdersOfAllStores)
					@Html.ValidationMessageFor(model => model.DisplayOrdersOfAllStores)
				</td>
			</tr>
		}
    </table>
}

@helper TabReturnRequestSettings()
{
	<div class="alert alert-info alert-dismissible">
		@T("Admin.Configuration.Settings.Order.ReturnRequestsDescription1")
		<br />
		@T("Admin.Configuration.Settings.Order.ReturnRequestsDescription2")
		<button type="button" class="close" data-dismiss="alert">&times;</button>
	</div>

    <table class="adminContent mb-3">
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.ReturnRequestsEnabled)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.ReturnRequestsEnabled)
                @Html.ValidationMessageFor(model => model.ReturnRequestsEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.NumberOfDaysReturnRequestAvailable)
            </td>
            <td class="adminData">
                @Html.SettingEditorFor(model => model.NumberOfDaysReturnRequestAvailable, null, new { postfix = T("Time.Days").Text })
                @Html.ValidationMessageFor(model => model.NumberOfDaysReturnRequestAvailable)
            </td>
        </tr>
    </table>
	
	@(Html.LocalizedEditor<OrderSettingsModel, OrderSettingsLocalizedModel>("setting-order-localized",
		@<table class="adminContent">
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Locales[item].ReturnRequestReasons)
				</td>
				<td class="adminData">
					@*IMPORTANT: Do not delete, this hidden element contains the id to assign localized values to the corresponding language *@
					@Html.HiddenFor(model => model.Locales[item].LanguageId)

					@Html.TextBoxFor(model => Model.Locales[item].ReturnRequestReasons)
					@Html.ValidationMessageFor(model => model.Locales[item].ReturnRequestReasons)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Locales[item].ReturnRequestActions)
				</td>
				<td class="adminData">
					@Html.TextBoxFor(model => model.Locales[item].ReturnRequestActions)
					@Html.ValidationMessageFor(model => model.Locales[item].ReturnRequestActions)
				</td>
			</tr>
		</table>
		,
		@<table class="adminContent">
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.ReturnRequestReasons)
				</td>
				<td class="adminData">
					@Html.TextBoxFor(model => model.ReturnRequestReasons)
					@Html.ValidationMessageFor(model => model.ReturnRequestReasons)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.ReturnRequestActions)
				</td>
				<td class="adminData">
					@Html.TextBoxFor(x => x.ReturnRequestActions)
					@Html.ValidationMessageFor(model => model.ReturnRequestActions)
				</td>
			</tr>
		</table>
	))
}